package com.wits.platform.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.wits.platform.common.constants.SysTabConstants;

@Entity
@Table(name = "wits_department")
public class Department extends BaseEntity{


	/**
	 * 
	 */
	private static final long serialVersionUID = -8605434580263644227L;

	public Department(){
		
	}
	private String deptId;
	
	private String deptCode;
	
	private String deptAbr;
	
	private String deptNameC;
	
	private String deptNameE;
	
	private String isEnable=SysTabConstants.SYSTAB_D_TNF_F;
	
	private String deptType;
	
	private int deptLevel;

	private List<Department> children = new ArrayList<Department>();

	private Department parent;
	
	/**
	 * 
	 */
	private Company company;


	/**
	 * 部门主管id
	 */
	private String empId;

	@Id
	@Column(name = "dept_id", nullable = false,length=36)
	public String getDeptId() {
		return deptId;
	}



	public void setDeptId(String deptId) {
		this.deptId = deptId;
	}

	@Column(name="dept_code",length=20)
	public String getDeptCode() {
		return deptCode;
	}



	public void setDeptCode(String deptCode) {
		this.deptCode = deptCode;
	}


	@Column(name="dept_abr",length=50)
	public String getDeptAbr() {
		return deptAbr;
	}



	public void setDeptAbr(String deptAbr) {
		this.deptAbr = deptAbr;
	}


	@Column(name="dept_name_c",length=200)
	public String getDeptNameC() {
		return deptNameC;
	}



	public void setDeptNameC(String deptNameC) {
		this.deptNameC = deptNameC;
	}


	@Column(name="dept_name_e",length=200)
	public String getDeptNameE() {
		return deptNameE;
	}



	public void setDeptNameE(String deptNameE) {
		this.deptNameE = deptNameE;
	}



	@Column(name="is_enable",length=1)
	public String getIsEnable() {
		return isEnable;
	}



	public void setIsEnable(String isEnable) {
		this.isEnable = isEnable;
	}


	@Column(name="dept_type",length=20)
	public String getDeptType() {
		return deptType;
	}



	public void setDeptType(String deptType) {
		this.deptType = deptType;
	}



	@Column(name="dept_level",length=4)
	public int getDeptLevel() {
		return deptLevel;
	}



	public void setDeptLevel(int deptLevel) {
		this.deptLevel = deptLevel;
	}

	
	@Column(name="emp_id",length=32)
	public String getEmpId() {
		return empId;
	}



	public void setEmpId(String empId) {
		this.empId = empId;
	}


	@ManyToOne
	@JoinColumn(name = "dept_id_p")
	public Department getParent() {
		return parent;
	}

	public void setParent(Department parent) {
		this.parent = parent;
	}

	@ManyToOne
	@JoinColumn(name="cpn_id")
	public Company getCompany() {
		return company;
	}



	public void setCompany(Company company) {
		this.company = company;
	}

	
	@OneToMany(mappedBy = "parent",fetch=FetchType.LAZY,cascade=CascadeType.REMOVE)
	public List<Department> getChildren() {
		return children;
	}

	public void setChildren(List<Department> children) {
		this.children = children;
	}
	


	@Override
	public String display() {
		// TODO Auto-generated method stub
		return this.deptNameC;
	}

}
